package com.lupan.tomcatStudy.javaStudy.chapter17;

import java.io.*;
import java.net.Socket;
import java.util.Scanner;

/**
 * TODO socket编程客户端
 *
 * @author lupan
 * @version 2016/1/19 0019
 */
public class Client {

    public static void main(String[] args) throws IOException {

        Socket s = new Socket("127.0.0.1",30000);

        //获取服务器端数据
        BufferedReader br = new BufferedReader(new InputStreamReader(s.getInputStream()));
        String line =  br.readLine();
        System.out.println("服务器端数据："+line);
//        br.close();

        //向服务器端传输数据
        Scanner scanner = new Scanner(System.in);

        while(scanner.hasNext()){
            Writer writer = new OutputStreamWriter(s.getOutputStream());
            writer.write(scanner.next());
        }



//        s.close();
    }
}
